//==============================================================================
// ParseUtils.hh
// ----------------------------------------------------------------------------
// These are utility functions to aid in parsing.  They are geared 
// toward line-by-line parsing of files. 
//
//
//------------------------------------------------------------------------------
// $Id: ParseUtils.hh,v 1.2 2000/03/31 19:33:46 kdurbin Exp $
//------------------------------------------------------------------------------
// $Log: ParseUtils.hh,v $
// Revision 1.2  2000/03/31 19:33:46  kdurbin
// *** empty log message ***
//
//
//==============================================================================
//.......1.........2.........3.........4.........5.........6.........7.........8
//

#include "LocalSTL.hh"
#include "CLibraryAdditions.hh"

#ifndef _PARSE_UTILS
#define _PARSE_UTILS

#define LINE_BUFFER_SIZE 5000

// Like the Perl Split function. 
void Split(string &inString,vector<string> &outVec,string delimiter);

// Like the command line cut function. 
bool CutString(string &inString,string &outString,int field,char delimiter);
bool Cut(string &inString,string &outString,int field,char delimiter);


bool StartsWith(string &,string &);
bool StartsWith(string &,char*);
bool Contains(string&,string&);
bool Contains(string&,char*);

bool ContainsOnlyDigits(string &line,int start, int end);


void StripTrailingSpace(string &theLine);
void StripLeadingSpaces(string&);
void StripWhiteSpace(string&);

int FindNextOf(vector<string> &KeywordList,string &Source,
						  int offset,
						  int &wordStart,
						  int &wordEnd);
						  
int FindNextInteger(string &Source,int offset,int &start,int &end);
int FindNextDouble(string &Source,int offset,int &start,int &end);

int GetAllIntegers(string &Line,vector<int> &AllInts);
int GetAllDoubles(string &Line,vector<double> &AllDoubles);


int    GetNextInteger(string &Source,int offset,int &newoffset);
int    NextInt(string &Source,int &offset);
int    GetNextLong(string &Source,int offset,int &newoffset);
long   NextLong(string &Source,int &offset);

double GetNextDouble(string &Source,int offset,int &newoffset);
double NextDouble(string &Source,int &offset);
float  NextFloat(string &Source,int &offset);


bool GetNextKeyword(vector<string> &KeywordList,
						string &Source,int offset,int &newoffset,string &word);

bool GetNextLineContaining(istream &fin,string &feature,string &lineOut);


// KJD These need to be revised, with stream at beginning.
bool GetNextLineContaining(istream &fin,const char*featureName,
									string &tempLine);

bool GetNextLineContaining(const char*fName1,const char* fName2,
									istream &inFile,string &tempLine);
bool GetNextLineContaining(istream &fin,vector<string>&keywordList,
									string &tempLine,int &keywordIdx);

void GetRemainderAfter(const char* featureName,string &tempLine,
                      string &outName);

void GetIntsFromLine(char *buffer,vector<int> &Values);
void GetIntsFromLine(string Line,vector<int> &Values);

string GetNextWSDelimitedString(string &Source,int offset, int &newoffset);
string NextString(string &Source,int &offset);

// Split In reference to the Perl split function. 
string SplitNext(string &Source,int &offset);

bool IsBase(char a);

void ShowHidden(string &line,ostream &fout);

bool ContainsOnlyWS(string &s);


void ToLowerCase(string &s);
void ToUpperCase(string &s);



#endif






